package com.lch.designpattern.strategy.pay;

import com.lch.designpattern.strategy.pay.payport.AliPay;
import com.lch.designpattern.strategy.pay.payport.Payment;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: liuchenhui
 * @create: 2019-06-23 12:53
 **/
public class PayFactory {
    private static Map<String, Payment> payMap = new HashMap<String, Payment>();

    static {
        payMap.put(PayTypeEnum.ALIPAY.name(), new AliPay());
    }

    static Payment getPay(String name) {
        if (!payMap.containsKey(name)) {
            return payMap.get(PayTypeEnum.ALIPAY.name());
        }
        return payMap.get(name);
    }
}
